package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface UserMapper {

    /*
     * 根据OpenId查询ID
     * */
    @Select("select * from user where openid =#{openid}")
    User getByOpenID(String openid);

    /*
     * 插入数据
     * */
    void insert(User user);

    /*
     * 根据ID查询用户
     * */
    @Select("select * from user where id =#{userid}")
    User getById(Long userId);


    /*
     *根据时间查询总用户数量
     * */
    @Select("select count(id) from user where user.create_time<=#{localBeginTime}")
    Integer gettotaluser(LocalDateTime localBeginTime);

    /*
     * 根据时间查询今日用户新增数量
     * */
    @Select("select count(id) from user where user.create_time between #{localBeginTime} and #{localEndTime}")
    Integer getnewuser(LocalDateTime localBeginTime, LocalDateTime localEndTime);


}
